package com.hema.auction.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hema.auction.R;
import com.hema.auction.bean.GoodsInfo;
import com.hema.auction.utils.GlideUtils;
import com.hema.auction.utils.Utils;

import java.util.List;

/**
 * author by john
 */

public class NewsAdapter extends BaseQuickAdapter<GoodsInfo, BaseViewHolder> {
    public NewsAdapter(List<GoodsInfo> data) {
        super(R.layout.layout_news_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsInfo item) {
        helper.setText(R.id.tv_dealer, item.getOwnerName());
        helper.setText(R.id.tv_market_price, Utils.priceUnitFormat(mContext, item.getPrice()));
        helper.setText(R.id.tv_deal_price, Utils.priceUnitFormat(mContext, item.getFinalPrice()));
        helper.setText(R.id.tv_save, Utils.savaFormat(mContext, item.getFinalPrice(), item.getPrice()));
        helper.setText(R.id.tv_date, Utils.timedate(item.getFinalTime()));
        ImageView view = helper.getView(R.id.iv_img);
        GlideUtils.load(mContext,item.getImg(),view);
        if (item.getNewGoodId() == null ||item.getNewGoodId().equals("null")) {
            helper.setVisible(R.id.tv_action, false);
        } else {
            helper.setVisible(R.id.tv_action, true);
        }

    }

}
